﻿using BLL;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using 纺织贸易管理系统.设置窗体;

namespace 后整理管理系统.数据分析
{
    public partial class 进仓日报表 : Form
    {
        private DateTime QueryDate = DateTime.Now;
        public 进仓日报表()
        {
            InitializeComponent();
        }
        private void query()
        {
           
                this.ShowWaitForm("正在生产报表，请等待.............");
                gridControl1.DataSource = 当月进仓报表.CreateReport(QueryDate);
                gridControl2.DataSource = 当月进仓报表.CreateCustomerReport(QueryDate);
                this.HideWaitForm();
            
        }

        private void 进仓日报表_Load(object sender, EventArgs e)
        {
            for(int i=0;i<10;i++)
            {
                comboBox1.Items.Add(DateTime.Now.Year - i);
            }
            comboBox1.Text = DateTime.Now.Year.ToString();
            comboBox2.Text = DateTime.Now.Month.ToString();
            QueryDate = DateTime.Parse ( comboBox1.Text+"-"+comboBox2.Text +"-01");
            query();
        }

        private void gridView1_Click(object sender, EventArgs e)
        {
            this.Invoke(new MethodInvoker(() => {
                gridControl3.DataSource = 当月进仓报表.CreateCustomerDetailReport(DateTime.Parse (comboBox1.Text +"-"+comboBox2.Text +"-"+ gridView1.GetFocusedRowCellValue("日期")));
            }));
        }

        private void uiComboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            QueryDate = DateTime.Parse(comboBox1.Text + "-" + comboBox2.Text + "-01");
            query();
        }

        private void uiSymbolButton1_Click(object sender, EventArgs e)
        {
            ExportFile.导出到文件(gridControl3, "生产进仓日报表");
        }
    }
}
